package org.xiaodongwei.jvm.op;

import org.xiaodongwei.jvm.exe.JVMStack;
import tech.medivh.classpy.classfile.bytecode.Instruction;
import tech.medivh.classpy.classfile.constant.ConstantPool;
import tech.medivh.classpy.classfile.jvm.Opcode;

public class FLoadOpCodeExecute extends OpCodeExecute {

    public FLoadOpCodeExecute(Opcode opcode, JVMStack jvmStack, ConstantPool constantPool) {
        this.opCode = opcode;
        this.jvmStack = jvmStack;
        this.constantPool = constantPool;
    }

    @Override
    public void execute(Instruction instruction) {
        switch (opCode) {
            case fload_0 -> {
                jvmStack.peek().getOperateStack().push(jvmStack.peek().getLocalVariable()[0]);
            }
            case fload_1 -> {
                jvmStack.peek().getOperateStack().push(jvmStack.peek().getLocalVariable()[1]);
            }
            case fload_2 -> {
                jvmStack.peek().getOperateStack().push(jvmStack.peek().getLocalVariable()[2]);
            }
            case fload_3 -> {
                jvmStack.peek().getOperateStack().push(jvmStack.peek().getLocalVariable()[3]);
            }
            default -> {

            }
        }
    }
}
